// Boost.STL2 library
//
//  Copyright Fernando Pelliccioni 2012.
//  Use, modification and distribution is subject to the Boost Software
//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//

#ifndef retro_range_HPP__
#define retro_range_HPP__


template <typename Range>
struct retro_range
{
	//TODO: range traits
	typedef	typename Range::value_type value_type;


	Range range_;

	explicit retro_range(Range range)
		: range_(range)
	{
	}
	
	value_type front() const
	{
		return range_.back();
	}
	
	value_type back() const
	{
		return range_.front();
	}
	
	void pop_front() 
	{
		range_.pop_back();
	}

	void pop_back() 
	{
		range_.pop_front();
	}

	bool empty() const
	{
		return range_.empty();
	}

	//void setFront(final T v) 
	//{
	//		range.setFront(v);
	//}
};


//TODO: chequear que Range sea BidirRange (Concept)
template <typename Range>
retro_range<Range> retro(Range r)
{
	return retro_range<Range>(r);
}

template <typename Range>
Range retro(retro_range<Range> r)
{
	return r.range_;	//TODO: no me gusta que range_ sea public
}

#endif // retro_range_HPP__